﻿
using Microsoft.Extensions.FileProviders;

public static class App
{
    public static AppSetting Setting { get; set; } = JsonHelper.Parse<AppSetting>("appsettings.json");

    public static string WebRootPath(HttpRequest request)
    {
        if(!Setting.UrlMapWebroot.TryGetValue(request.Host.Value,out string path))
        {
            path = "";
        }
        return path + request.Path;
        
    }

    public static void MapPath(this IApplicationBuilder app)
    {
        app.Use(async (ctx, next) =>
        {

            ctx.Request.Path = App.WebRootPath(ctx.Request);
            await next(ctx);
        });
    }

}

public class AppSetting
{
    public Dictionary<string, string> UrlMapWebroot { get; set; }



}

public class _FileProvider : PhysicalFileProvider
{
    public _FileProvider(string root) : base(root)
    {
        
    }

    public new string Root {  get; set; }
}
